package com.sherlochao.dao.impl;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;

import com.sherlochao.dao.CommentDao;
import com.sherlochao.model.Comment;


@Repository("commentDao")
public class CommentDaoImpl implements CommentDao{
	
	@Resource
	private SessionFactory sessionFactory;
	
	public Session getSession() {
		return sessionFactory.getCurrentSession();
	}

	@Override
	public Comment get(String id) {
		String hql = "from Comment where id = ?";
		Query query = this.getSession().createQuery(hql);
		query.setString(0, id);
		return (Comment)query.uniqueResult();
	}

	@Override
	public String save(Comment entity) {
		return (String)this.getSession().save(entity);
	}

	@Override
	public void delete(String id) {
		
	}

	@Override
	public Comment load(String id) {
		return null;
	}

}
